<div id="containter"></div>
<hr/>
<input type="text" id="txtChat" /><button onclick="sendMsg()">send</button>


<script>
	var webSocket = new WebSocket("ws://localhost:8080/ishare/ws/chatroom");
	function sendMsg(){
		var msg = document.getElementById("txtChat").value;
		webSocket.send(msg);
		//clear msg
		document.getElementById("txtChat").value="";
	}
	webSocket.onmessage = function(evt){
		console.log(evt.data);
		//get old value of container
		var allMsg = document.getElementById("containter").innerHTML;
		//add new msg
		document.getElementById("containter").innerHTML = allMsg + evt.data + "<br/>";
	};
	
</script>

